// Using jQuery with Other Libraries
try {
jQuery.noConflict();

// Blogger extensions Options
var BloggerExtOptions = {
    core_version: '0.7.2'
};

var BloggerExtUserPrefs = {};

var BloggerExt = {};
jQuery.extend( BloggerExt, {
        extensions: [],
            user_prefs: [],
        hooks: [],

        register: function(flag, opts) {
            BloggerExt.extensions.push(flag);
            if(opts != undefined) jQuery.extend(BloggerExtOptions, opts);
            if (typeof BloggerExt[flag]['user_pref'] != 'undefined') BloggerExt.user_prefs.push(flag);
        },

        registerHook: function (fn) {
            BloggerExt.hooks.push(fn);
        },

        process: function() {
            jQuery(document).ready( function(){

                // Use Cookie User Preference over BloggerExtOptions.
                var cookieUserPrefs = BloggerExt.cookie('BloggerExtUserPrefs');
                if (cookieUserPrefs) {
                  try {
                    BloggerExtUserPrefs = BloggerExt.parseJSON(cookieUserPrefs);
                    jQuery.extend(BloggerExtOptions, BloggerExtUserPrefs);
                  }catch(ex) {}
                }

                var flag;
                while( flag = BloggerExt.extensions.pop() ) {
                    if(BloggerExtOptions[flag]) { try { BloggerExt[flag](); }catch(e){} }
                }
                // run hooks
                BloggerExt.processHook();
            });
        },

        processHook: function() {
            // Try hook Blogger _WidgetManager_HandleControllerResult
            if(BloggerExt.isListMode() && (typeof BloggerExt._WidgetManager_HandleControllerResult == 'undefined') ) {
                BloggerExt._WidgetManager_HandleControllerResult = _WidgetManager._HandleControllerResult;
                _WidgetManager._HandleControllerResult = function() {
                    try {
                        // Call _WidgetManager_HandleControllerResult
                        BloggerExt._WidgetManager_HandleControllerResult.apply(this, arguments);
                        // call register hooks
                        for (var idx in BloggerExt.hooks) {
                            var fn = BloggerExt.hooks[idx];
                            fn.call(this);
                        }
                    }catch(e) {
                    }
                }
            }
        },

        registerAndProcess: function(flag, opts) {
            BloggerExt.register(flag,opts);
            BloggerExt.process();
        },

        isListMode: function() {
            var isList = false;
            if ( document.location.href.split('/').pop() == "" || document.location.href.split('/').pop() == "index.html") {
                // Suppose the url include index.html
                isList = true;
            }else if(document.location.href.indexOf("/search/label/") >= 0) {
                // Suppose the url search label
                isList = true;
            }else if((document.location.href.indexOf("/search?") >= 0) || (document.location.href.indexOf("archive.html") >= 0)) {
                // Suppose the url include search or archive
                isList = true;
            }
            return isList;
        },

        isItemMode: function() {
            return (!BloggerExt.isListMode());
        }
});

// Add toJSON and parseJSON utilities
(function ($) {
    var m = {
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        s = {
            'array': function (x) {
                var a = ['['], b, f, i, l = x.length, v;
                for (i = 0; i < l; i += 1) {
                    v = x[i];
                    f = s[typeof v];
                    if (f) {
                        v = f(v);
                        if (typeof v == 'string') {
                            if (b) {
                                a[a.length] = ',';
                            }
                            a[a.length] = v;
                            b = true;
                        }
                    }
                }
                a[a.length] = ']';
                return a.join('');
            },
            'boolean': function (x) {
                return String(x);
            },
            'null': function (x) {
                return "null";
            },
            'number': function (x) {
                return isFinite(x) ? String(x) : 'null';
            },
            'object': function (x) {
                if (x) {
                    if (x instanceof Array) {
                        return s.array(x);
                    }
                    var a = ['{'], b, f, i, v;
                    for (i in x) {
                        v = x[i];
                        f = s[typeof v];
                        if (f) {
                            v = f(v);
                            if (typeof v == 'string') {
                                if (b) {
                                    a[a.length] = ',';
                                }
                                a.push(s.string(i), ':', v);
                                b = true;
                            }
                        }
                    }
                    a[a.length] = '}';
                    return a.join('');
                }
                return 'null';
            },
            'string': function (x) {
                if (/["\\\x00-\x1f]/.test(x)) {
                    x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
                        var c = m[b];
                        if (c) {
                            return c;
                        }
                        c = b.charCodeAt();
                        return '\\u00' +
                            Math.floor(c / 16).toString(16) +
                            (c % 16).toString(16);
                    });
                }
                return '"' + x + '"';
            }
        };

    $.toJSON = function(v) {
        var f = isNaN(v) ? s[typeof v] : s['number'];
        if (f) return f(v);
    };

    $.parseJSON = function(v, safe) {
        if (safe === undefined) safe = $.parseJSON.safe;
        if (safe && !/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(v))
            return undefined;
        return eval('('+v+')');
    };

    $.parseJSON.safe = false;

})(BloggerExt);

// Add jQuery Cookie plugins
BloggerExt.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

// Register hide_navbar
BloggerExt.hide_navbar = function() {
    if(BloggerExtOptions.fade_navbar) {
        jQuery('#navbar').fadeTo(0,0).hover( function() { jQuery(this).fadeTo("fast", 1); }, function() { jQuery(this).fadeTo("fast", 0); });
    }else {
        jQuery('#navbar').hide();
    }
};
BloggerExt.hide_navbar.user_pref = function() {
    var prefs = [];
    prefs.push({tab_name: 'core', name: 'hide_navbar', display_name:'Hide Navbar:', data_type:'bool', 'default_value': BloggerExtOptions['hide_navbar'] });
    prefs.push({tab_name: 'core', name: 'fade_navbar', display_name:'Fade Navbar:', data_type:'bool', 'default_value': BloggerExtOptions['fade_navbar'] });
    return prefs;
};
BloggerExt.hide_navbar.update_pref = function(prefs) {
  BloggerExtUserPrefs['hide_navbar'] = (typeof prefs['hide_navbar'] != 'undefined') ? true : false ;
  BloggerExtUserPrefs['fade_navbar'] = (typeof prefs['fade_navbar'] != 'undefined') ? true : false;
};
BloggerExt.register('hide_navbar', { hide_navbar: true, fade_navbar: false} );


// Register hide_sidebar_html_markup
BloggerExt.hide_sidebar_html_markup = function() {
    jQuery('.HTML .title').contains('##HIDEME##').each( function(){ jQuery(this).parent().hide(); } );
};
BloggerExt.hide_sidebar_html_markup.user_pref = function() {
    var prefs = [];
    prefs.push({tab_name: 'core', name: 'hide_sidebar_html_markup', display_name:'Hide Sidebar:', data_type:'bool', 'default_value': BloggerExtOptions['hide_sidebar_html_markup'] });
    return prefs;
};
BloggerExt.hide_sidebar_html_markup.update_pref = function(prefs) {
  BloggerExtUserPrefs['hide_sidebar_html_markup'] = (typeof prefs['hide_sidebar_html_markup'] != 'undefined') ? true : false ;
};
BloggerExt.register('hide_sidebar_html_markup', { hide_sidebar_html_markup: true} );


// User Preference
BloggerExt.user_preference = function() {

  /**
   * Create User Preference.
   */
  function createPrefsElements(prefs) {
        var inputHtmls = {
            'string': function(pref) {
                var chtml = '<label for="'+pref['name']+'">'+ pref['display_name'] +'</label>';
                chtml += '<input type="text" value="'+pref['default_value']+'" name="'+pref['name']+ '" /><br />';
                return chtml;
            },
            'bool': function(pref) {
                var chtml = '<label for="'+pref['name']+'">'+ pref['display_name'] +'</label>';
                var cchecked = (pref['default_value']) ? ' checked="checked"' : '';
                chtml += '<input type="checkbox" value="true" name="'+pref['name']+ '"'+ cchecked +' /><br />';
                return chtml;
            },
            'enum': function(pref) {
                var chtml = '<label for="'+pref['name']+'">'+ pref['display_name'] +'</label>';
                chtml += '<select name="'+pref['name']+'">';
                for(var i=0; i<pref['options'].length; i++) {
                  var opt_value = pref['options'][i]['value'];
                  var opt_display = pref['options'][i]['display'];
                  var cchecked = (pref['default_value'] == opt_value) ? ' selected' : '';
                  chtml += '<option value="'+opt_value+'" '+cchecked+'>'+opt_display+'</option>';
                }
                chtml += '</select><br />';
                return chtml;
            }
        };

        for(var i=0; i<prefs.length; i++) {
            var pref = prefs[i];
            var $prefDiv = $userPrefContainer.find('#pref_'+pref['tab_name']);
            if($prefDiv.size() == 0) {
                $prefDiv = jQuery('<div id="pref_'+pref['tab_name']+'" class="fragment"></div>');
                $userPrefContainer.append($prefDiv);
            }
            var f = inputHtmls[pref['data_type']];
            $prefDiv.append(jQuery(f(pref)));

            var $prefTab = $userPrefTabs.find('#preftab_'+pref['tab_name']);
            if($prefTab.size() == 0) {
            $prefTab = jQuery('<li id="preftab_'+pref['tab_name']+'"></li>').css({'display': 'inline'});  				var $aTab = jQuery('<a href="#pref_'+pref['tab_name']+'">'+pref['tab_name']+'</a>');
                  $aTab.click(function(e) {
                  var containId = jQuery(this).parent().attr('id').replace('preftab_', 'pref_');
            $userPrefContainer.find('div.fragment').not('#'+containId).hide();
            $userPrefTabs.find('li').removeClass('tabs-selected');
            jQuery(this).parent().addClass('tabs-selected');
                  jQuery('#'+containId).show();
                  return false;
                });

                $prefTab.append($aTab);
                $userPrefTabs.append($prefTab);
                delete $aTab;
                delete $prefTab;
            }
        }
  };


  /**
   * Update User Preference.
   */
  function updatePrefsElements(ev) {

    function fieldValue(el, successful) {
      var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
      if (typeof successful == 'undefined') successful = true;

      if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
          (t == 'checkbox' || t == 'radio') && !el.checked ||
          (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
          tag == 'select' && el.selectedIndex == -1))
              return null;

      if (tag == 'select') {
          var index = el.selectedIndex;
          if (index < 0) return null;
          var a = [], ops = el.options;
          var one = (t == 'select-one');
          var max = (one ? index+1 : ops.length);
          for(var i=(one ? index : 0); i < max; i++) {
              var op = ops[i];
              if (op.selected) {
                  // extra pain for IE...
                  var v = jQuery.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value;
                  if (one) return v;
                  a.push(v);
              }
          }
          return a;
      }
      return el.value;
    };

    var user_prefs = {};
    var $inputs = jQuery('#user_pref_container').find('input[@type=checkbox], input[@type=text], select');

    $inputs.each( function(i) {
      var vv = fieldValue(this, true);
      if (vv == null) return;
      user_prefs[this.name] = vv;
    });

    // callback every plugins for update
        for (var i=0; i < BloggerExt.user_prefs.length; i++) {
            var plugin_name = BloggerExt.user_prefs[i];
            if (typeof BloggerExt[plugin_name]['update_pref'] != 'undefined') {
              var plugin_prefs = BloggerExt[plugin_name]['update_pref'].call(document, user_prefs);
            }
        }

    savePrefsElements();
    jQuery(ev.target).attr('disabled', true).val('Saved! Please reload');

  };

  /**
   * Save User Preference.
   */
  function savePrefsElements() {
    var jsonBloggerExtUserPrefs = BloggerExt.toJSON(BloggerExtUserPrefs);
    BloggerExt.cookie('BloggerExtUserPrefs', jsonBloggerExtUserPrefs, {expires: 180});
  };

  /*
   * User Preference Plugin initialize.
   */
    var $userPrefContainer = jQuery('#user_pref_container');
  var $userPrefTabs = null;
  // if user_pref_container div exists
    if($userPrefContainer.size()>0) {
    $userPrefTabs = jQuery('<ul class="tabs-nav anchors"></ul>').css({'list-style-type': 'none', 'list-style-position': 'outside'});
    $userPrefContainer.append($userPrefTabs);
    $userPrefContainer.append('<div class="menuline" style="clear: both;"></div>');

        for (var i=0; i < BloggerExt.user_prefs.length; i++) {
            var plugin_name = BloggerExt.user_prefs[i];
            var plugin_prefs = BloggerExt[plugin_name]['user_pref'].call(document);
            createPrefsElements(plugin_prefs);
        }
    $userPrefContainer.append( jQuery('<input type="button" value="update"></input>').click(updatePrefsElements));
    $userPrefContainer.find('div.fragment').hide().eq(0).show();
    $userPrefTabs.find('li').eq(0).toggleClass('tabs-selected');
    }

};
BloggerExt.register('user_preference', {user_preference: true} );


// Register sidebar_widget_expandable
BloggerExt.sidebar_widget_expandable = function() {

    // find containers to expandable.
    jQuery.each(BloggerExtOptions.sidebar_widget_expandable_ids, function(i) {
        // find widget container with class name
        jQuery('#'+this).each( function(j){
                var widgetId = this.id;
                var titleObj = jQuery(this).children('h2:eq(0)');
                var contentObj = jQuery(this).children('div:eq(0)');
                var animate_str = "";
                if(BloggerExtOptions.sidebar_widget_expandable_animate) {
                    var animate_str = "'fast',";
                }else {
                    var animate_str = ").each(";
                }
                var link = "<span class=\"sidebar-widget-expand\"><a onclick=\"jQuery('#"+widgetId+" .widget-content').toggle("+animate_str
                          +"function(){ "
                          +"  jQuery(this).is(':hidden') ? "
                          +"  jQuery('#"+widgetId+" a:eq(0)').html(BloggerExtOptions.sidebar_widget_expan_title) : "
                          +"  jQuery('#"+widgetId+" a:eq(0)').html(BloggerExtOptions.sidebar_widget_collapse_title)"
                          +"});\">"+BloggerExtOptions.sidebar_widget_expan_title+"</a></span>";
                titleObj.prepend(link);
                contentObj.hide();
        });
    });

};
BloggerExt.sidebar_widget_expandable.user_pref = function() {
    var prefs = [];
    prefs.push({tab_name: 'widget', name: 'sidebar_widget_expandable', display_name:'Expandable:', data_type:'bool', 'default_value': BloggerExtOptions['sidebar_widget_expandable'] });
    prefs.push({tab_name: 'widget', name: 'sidebar_widget_expandable_animate', display_name:'Expand Animate:', data_type:'bool', 'default_value': BloggerExtOptions['sidebar_widget_expandable_animate'] });
    return prefs;
};
BloggerExt.sidebar_widget_expandable.update_pref = function(prefs) {
  BloggerExtUserPrefs['sidebar_widget_expandable'] = (typeof prefs['sidebar_widget_expandable'] != 'undefined') ? true : false ;
  BloggerExtUserPrefs['sidebar_widget_expandable_animate'] = (typeof prefs['sidebar_widget_expandable_animate'] != 'undefined') ? true : false ;
};
BloggerExt.register('sidebar_widget_expandable' ,  {
    sidebar_widget_expandable: true,
    sidebar_widget_expandable_version: 1.2,
    sidebar_widget_expandable_animate: false,
    sidebar_widget_expan_title: '[+]',
    sidebar_widget_collapse_title: '[-]',
    sidebar_widget_expandable_ids: ['Label1','LinkList1','BlogArchive1']
});



// Register replace_smiley
BloggerExt.replace_smiley = function() {

    jQuery('div.blog-posts').find('.post-body, .comment-body, .comment-body-author').each( function (i) {
            var newHtml = jQuery(this).html();
            for( var idx in BloggerExtOptions.smilies ) {
                newHtml = newHtml.replace(BloggerExtOptions.smilies[idx][0], BloggerExtOptions.smilies[idx][1], "gm");
            }
            // fixed to no replace, if content is the same. and not eval script
            if(jQuery(this).html().length != newHtml.length) jQuery(this).attr("innerHTML", newHtml );

    });

};
BloggerExt.register('replace_smiley' ,  {
    replace_smiley: true,

    smilies: [
                [' :)', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/1.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :(', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/2.gif" style="border:0; margin:0; padding:0;" /> '],
                [' ;)', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/3.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :D', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/4.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :p', '<img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/10.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :$', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/32.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :-k', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/11.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :*', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/11.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :@', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/14.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :#', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/33.gif" style="border:0; margin:0; padding:0;" /> '],
                [' [-(', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/33.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :x', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/35.gif" style="border:0; margin:0; padding:0;" /> '],
                [' :o', ' <img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/13.gif" style="border:0; margin:0; padding:0;" /> ']
             ]
});
BloggerExt.registerHook(BloggerExt.replace_smiley);


// Register replace_continue_markup
BloggerExt.replace_continue_markup = function() {
    // make continue...
    if(BloggerExtOptions.replace_continue_markup_animate) {
        var animate_str = "'fast',";
    }else {
        var animate_str = ").each(";
    }
    if( BloggerExt.isListMode() ) {
        jQuery('div.post-body').contains('##CONTINUE##').each( function (i) {
            if (BloggerExtOptions.replace_continue_markup_as_link) {
                var postSummaryLength =  jQuery(this).html().indexOf('##CONTINUE##');
                var postLinkHtml = "<span class='post-body-continue'><a href='"
                                  +jQuery(this).parent().find('.post-title a').attr('href')
                                  +"'>"+BloggerExtOptions.continue_markup_expand_title+"</a></span>";
                jQuery(this).html( jQuery(this).html().substr(0, postSummaryLength) + postLinkHtml );
            }else {
                var postLinkHtml = "<span class=\"post-body-continue\"><a id=\"post-body-toggle" + i + "\" onclick=\"jQuery('#post-body-hide"
                                  +i+"').toggle("+animate_str
                                  +"function(){"
                                  +"  jQuery(this).is(':hidden') ?"
                                  +"    jQuery('#post-body-toggle"+i+"').html(BloggerExtOptions.continue_markup_expand_title) : "
                                  +"    jQuery('#post-body-toggle"+i+"').html(BloggerExtOptions.continue_markup_collapse_title)"
                                  +"});\">"+BloggerExtOptions.continue_markup_expand_title+"</a></span>"
                                  +"<div style='display:none' id='post-body-hide"+i+"'>";
                jQuery(this).html( (jQuery(this).html().replace(/##CONTINUE##/g, postLinkHtml)) + "</div>");
            }
        });

    }else {
        jQuery('div.post-body').contains('##CONTINUE##').each( function (i) {
            jQuery(this).html(jQuery(this).html().replace(/##CONTINUE##/g,""));
        });
    }

    // support make continue by classname fullpost ...
    if( BloggerExt.isListMode() ) {
        // some bugfix jQuery('#fullpost') only return first match ?? why?? change to css selector mode.
        jQuery('div.post-body').each( function (i) {
            if( jQuery(this).find('#fullpost').length == 1 ) {
                if (BloggerExtOptions.replace_continue_markup_as_link) {
                    var postLinkHtml = "<span class='post-body-continue'><a href='"
                                      +jQuery(this).parent().find('.post-title a').attr('href')
                                      +"'>"+BloggerExtOptions.continue_markup_expand_title+"</a></span>";
                    jQuery(this).find('#fullpost').before( jQuery(postLinkHtml) ).remove();

                }else {
                    var postLinkHtml = "<span class=\"post-body-continue\"><a id=\"post-body-toggle" + i + "\" onclick=\"jQuery('.post-body-hide"
                                      +i+"').toggle("+animate_str
                                      +"function(){"
                                      +"  jQuery(this).is(':hidden') ? "
                                      +"    jQuery('#post-body-toggle"+i+"').html(BloggerExtOptions.continue_markup_expand_title) : "
                                      +"    jQuery('#post-body-toggle"+i+"').html(BloggerExtOptions.continue_markup_collapse_title)"
                                      +"});\">"+BloggerExtOptions.continue_markup_expand_title+"</a></span>";
                    jQuery(this).find('#fullpost').before( jQuery(postLinkHtml) ).addClass("post-body-hide"+i).css('display', 'none');
                }
            }
        });
    }else {
        jQuery('div.post-body #fullpost').each( function (i) {
                jQuery(this).show();
        });
    }
};
BloggerExt.replace_continue_markup.user_pref = function() {
    var prefs = [];
    prefs.push({tab_name: 'continue', name: 'replace_continue_markup', display_name:'Read More:', data_type:'bool', 'default_value': BloggerExtOptions['replace_continue_markup'] });
    prefs.push({tab_name: 'continue', name: 'replace_continue_markup_animate', display_name:'Animate:', data_type:'bool', 'default_value': BloggerExtOptions['replace_continue_markup_animate'] });
    prefs.push({tab_name: 'continue', name: 'replace_continue_markup_as_link', display_name:'Use Link:', data_type:'bool', 'default_value': BloggerExtOptions['replace_continue_markup_as_link'] });
    return prefs;
};
BloggerExt.replace_continue_markup.update_pref = function(prefs) {
  BloggerExtUserPrefs['replace_continue_markup'] = (typeof prefs['replace_continue_markup'] != 'undefined') ? true : false ;
  BloggerExtUserPrefs['replace_continue_markup_animate'] = (typeof prefs['replace_continue_markup_animate'] != 'undefined') ? true : false ;
  BloggerExtUserPrefs['replace_continue_markup_as_link'] = (typeof prefs['replace_continue_markup_as_link'] != 'undefined') ? true : false ;
};

BloggerExt.register('replace_continue_markup' ,  {
    replace_continue_markup: true,
    replace_continue_markup_version: 1.1,
    replace_continue_markup_animate: false,
    replace_continue_markup_as_link: false,
    continue_markup_expand_title: '[+] Read More....',
    continue_markup_collapse_title: '[-] Summary....'
});
BloggerExt.registerHook(BloggerExt.replace_continue_markup);



// Register author_comment_highlighting
BloggerExt.author_comment_highlighting = function() {

    if( BloggerExt.isItemMode() ) {
        // try to find profile
        if(BloggerExtOptions.author_comment_highlighting_profile == '') {
            jQuery('.profile-link:first').each(function() {
                    BloggerExtOptions.author_comment_highlighting_profile = jQuery(this).attr('href').split('/')[4];
            });
        }
        if(BloggerExtOptions.author_comment_highlighting_profile != '') {
            var arAuthors = BloggerExtOptions.author_comment_highlighting_profile.split(',');
            jQuery('#comments-block .comment-author').each( function(i) {
                for( var idx in arAuthors) {
                    var author = arAuthors[idx];
                    try{
                        if( ((jQuery(this).find('a:eq(1)').attr('href').split('/'))[4]) == author ) {
                            jQuery(this).next().removeClass().addClass('comment-body-author').css(BloggerExtOptions.author_comment_highlighting_style);
                        }
                    }catch(e){}
                }
            });
        }
    }
};
BloggerExt.register('author_comment_highlighting' ,  {
    author_comment_highlighting: true,
    author_comment_highlighting_version: 0.2,
    author_comment_highlighting_profile: '',
    author_comment_highlighting_style: { 'color': '#C30014', 'font-width': 'bold' }
});


// Register LabelCloud
BloggerExt.labelcloud = function() {

    var arLabels = new Array();
    var arLabelCounts = new Array();
    var labelMaxCount = 0;

    // by delicious
    function s(a,b,i,x){
        if(a>b){ var m=(a-b)/Math.log(x),v=a-Math.floor(Math.log(i)*m); }
        else{ var m=(b-a)/Math.log(x),v=Math.floor(Math.log(i)*m+a); }
        return v;
    }

    jQuery('#'+BloggerExtOptions.labelcloud_widget_id+' div li').each(function(idx){
        var txt = jQuery(this).text();
        var i = txt.indexOf('(');
        var j = txt.indexOf(')');
        var labelCount = txt.substr(i+1, (j-i-1));
        arLabels[idx] = this;
        arLabelCounts[idx] = labelCount;
        if(parseInt(labelCount) > labelMaxCount) labelMaxCount = parseInt(labelCount);
    });
    for (var i=0; i<arLabels.length; i++) {
        var liObj = jQuery(arLabels[i]);
        var aObj = liObj.find('a');
        var v = s(BloggerExtOptions.labelcloud_minFontSize, BloggerExtOptions.labelcloud_maxFontSize, arLabelCounts[i], labelMaxCount);
        var r = s(BloggerExtOptions.labecloud_minColor[0], BloggerExtOptions.labelcloud_maxColor[0], arLabelCounts[i], labelMaxCount);
        var g = s(BloggerExtOptions.labecloud_minColor[1], BloggerExtOptions.labelcloud_maxColor[1], arLabelCounts[i], labelMaxCount);
        var b = s(BloggerExtOptions.labecloud_minColor[2], BloggerExtOptions.labelcloud_maxColor[2], arLabelCounts[i], labelMaxCount);
        if(aObj.length == 1) {
            aObj.css({'font-size': v, 'color': 'RGB('+r+','+g+','+b+')'});
            if (BloggerExtOptions.labelcloud_display_count) aObj.html(aObj.html() + ' (' + arLabelCounts[i]  + ')');
            liObj.html(aObj);
        }else {
            liObj.css({'font-size': v, 'color': 'RGB('+r+','+g+','+b+')'});
        }
        liObj.css({'display': 'inline'});
    }
};
BloggerExt.labelcloud.user_pref = function() {
    var prefs = [];
    prefs.push({tab_name: 'widget', name: 'labelcloud', display_name:'Label Cloud:', data_type:'bool', 'default_value': BloggerExtOptions['labelcloud'] });
    return prefs;
};
BloggerExt.labelcloud.update_pref = function(prefs) {
  BloggerExtUserPrefs['labelcloud'] = (typeof prefs['labelcloud'] != 'undefined') ? true : false ;
};
BloggerExt.register('labelcloud' ,  {
    labelcloud: true,
    labelcloud_version: 0.3,
    labelcloud_widget_id: 'Label1',
    labelcloud_maxFontSize: 24,
    labelcloud_minFontSize: 10,
    labelcloud_maxColor: [168,181,248],
    labecloud_minColor: [0,0,0],
    labelcloud_display_count: false
});




// Register sidebar_widget_icon
BloggerExt.sidebar_widget_icon = function() {

    // find containers to expandable.
    for (var widgetId in BloggerExtOptions.sidebar_widget_icons) {
        var widgetImg = BloggerExtOptions.sidebar_widget_icons[widgetId];

        // find widget container with class name
        jQuery('#'+widgetId).each( function(j){
                var titleObj = jQuery(this).children('h2:eq(0)');
                titleObj.prepend(widgetImg);
        });
    }

};
BloggerExt.register('sidebar_widget_icon' ,  {
    sidebar_widget_icon: true,
    sidebar_widget_icons: {}
});


// Register bookmark_buttons
BloggerExt.bookmark_buttons = function() {

    // process each posts at ListMode and ItemMode
    jQuery('div.post').each( function (i) {
            var post_titleLinkObj = jQuery(this).find('.post-title a');
            var post_title = encodeURIComponent(post_titleLinkObj.text());
            var post_url = encodeURIComponent(post_titleLinkObj.attr('href'));
            var post_desc = encodeURIComponent(jQuery(this).find('.post-body').text().substr(0,500));

            var buttonsHTML = '';
            for (var i=0; i < BloggerExtOptions.bookmark_buttons_bookmarklets.length; i++) {
                var img = BloggerExtOptions.bookmark_buttons_bookmarklets[i][0];
                var alt = BloggerExtOptions.bookmark_buttons_bookmarklets[i][1];
                var urlTempl = BloggerExtOptions.bookmark_buttons_bookmarklets[i][2];

                if (typeof BloggerExtOptions['bookmark_btn_'+alt] != 'undefined' && BloggerExtOptions['bookmark_btn_'+alt] == false) continue;

                var url = urlTempl.replace('%URL%', post_url, "gm");
                url = url.replace('%TITLE%', post_title, "gm");
                url = url.replace('%DESC%', post_desc, "gm");

                buttonsHTML += '<a class="bookmark_button" href="'+url+'" alt="'+alt+'"><img src="'+img+'" alt="'+alt+'"></a>';
            }
            jQuery(this).find('.post-footer .post-icons').after( BloggerExtOptions.bookmark_buttons_template.replace('%BOOKMARK_BUTTONS%', buttonsHTML, "gm"));
    });
};
BloggerExt.bookmark_buttons.user_pref = function() {
    var prefs = [];
    prefs.push({tab_name: 'bookmark', name: 'bookmark_buttons', display_name:'Add Bookmark:', data_type:'bool', 'default_value': BloggerExtOptions['bookmark_buttons'] });
  for (var i=0; i < BloggerExtOptions.bookmark_buttons_bookmarklets.length; i++) {
    var alt = BloggerExtOptions.bookmark_buttons_bookmarklets[i][1];
    prefs.push({tab_name: 'bookmark', name: 'bookmark_btn_'+alt, display_name: alt, data_type:'bool', 'default_value': BloggerExtOptions['bookmark_btn_'+alt] });
  }
    return prefs;
};
BloggerExt.bookmark_buttons.update_pref = function(prefs) {
  BloggerExtUserPrefs['bookmark_buttons'] = (typeof prefs['bookmark_buttons'] != 'undefined') ? true : false ;
  for (var i=0; i < BloggerExtOptions.bookmark_buttons_bookmarklets.length; i++) {
    var alt = BloggerExtOptions.bookmark_buttons_bookmarklets[i][1];
    var n =  'bookmark_btn_' + alt;
    BloggerExtUserPrefs[n] = (typeof prefs[n] != 'undefined') ? true : false ;
  }
};
BloggerExt.register('bookmark_buttons' ,  {
    bookmark_buttons: true,
    bookmark_buttons_version: 0.2,
    bookmark_buttons_template: '<span class="post-bookmarks">%BOOKMARK_BUTTONS%</span>',
    bookmark_buttons_bookmarklets: [
        [
          'http://blogger.ext2.googlepages.com/hemidemi.gif',
          'HEMiDEMi',
          'http://www.hemidemi.com/user_bookmark/new?via=sticker&url=%URL%&title=%TITLE%&description=%DESC%'
        ] ,
        [
          'http://blogger.ext2.googlepages.com/yahoo-myweb.png',
          'Yahoo',
          'http://tw.myweb2.search.yahoo.com/myresults/bookmarklet?ei=UTF-8&u=%URL%&t=%TITLE%&d=%DESC%'
        ],
        [
          'http://blogger.ext2.googlepages.com/myshare.gif',
          'MyShare',
          'http://myshare.url.com.tw/index.php?func=newurl&from=mysharepop&NewsMaster=1&url=%URL%&desc=%TITLE%&contents=%DESC%'
        ],
        [
        'http://funp.com/images/tools/post_05.gif',
        'funp',
        'http://funp.com/pages/submit/add.php?via=tools&ei=UTF-8&url=%URL%&s=%TITLE%&t=%DESC%'
        ],
        [
          'http://blogger.ext2.googlepages.com/delicious.png',
          'del.icio.us',
          'http://del.icio.us/post?url=%URL%&title=%TITLE%'
        ],
        [
          'http://blogger.ext2.googlepages.com/technorati.png',
          'Technotati',
          'http://technorati.com/faves?sub=%TITLE%&add=%URL%'
        ],
        [
          'http://blogger.ext2.googlepages.com/furl.gif',
          'FURL',
          'http://furl.net/storeIt.jsp?&u=%URL%&t=%TITLE%'
        ],
        [
          'http://blogger.ext2.googlepages.com/digg.png',
          'digg it!',
          'http://www.digg.com/submit?phase=2&url=%URL%&title=%TITLE%'
        ]
    ]
});
BloggerExt.registerHook(BloggerExt.bookmark_buttons);



// Run All Register Process
BloggerExt.process();
}catch (e) { }